import requests

from api.zuoye_api import ZuoYe
from common.emp_id import EmpId
from common.ihrm_ass import IhrmAssert
from common.token_ihrm import TokenIhrm


class TestCity:

    def setup_class(self):
        self.token = TokenIhrm.token_login()

    def test_ysy(self):
        ysy4_body = {"name": "周天狗", "code": "38"}
        test_reps = ZuoYe.test_ysy4(self.token, ysy4_body)
        print(test_reps.json())
        IhrmAssert.login_assert(test_reps, 200, True, 10000, '操作成功！')

    def test_ysy2(self):
        test_reps = ZuoYe.test_ysy3(EmpId.emp_ihrm(), self.token)
        print(test_reps.text)
        IhrmAssert.login_assert(test_reps, 200, True, 10000, '操作成功！')

    def test_ysy3(self):
        ysy4_body = {"name": "周大天狗", "code": "38"}
        test_reps = ZuoYe.test_ysy5(EmpId.emp_ihrm(), self.token, ysy4_body)
        print(test_reps.json())
        IhrmAssert.login_assert(test_reps, 200, True, 10000, '操作成功！')

    def test_ysy4(self):
        test_reps = ZuoYe.test_ysy6(EmpId.emp_ihrm(), self.token)
        print(test_reps.json())


#
#
#     def test_ysy3(self):
#         ysy3_utl = "http://ihrm2-test.itheima.net/api/company/department/1063678149528784896"
#         ysy3_header = {"Authorization": "5755f3f6-4dba-44da-b269-bc9929d26a58"}
#         ysy3_reps = requests.get(url=ysy3_utl, headers=ysy3_header)
#         print(ysy3_reps.text)
#
#         assert 200 == ysy3_reps.status_code
#         assert True == ysy3_reps.json().get("success")
#         assert 10000 == ysy3_reps.json().get("code")
#         assert '操作成功！' == ysy3_reps.json().get("message")
#
#     def test_ysy4(self):
#         ysy4_url = "http://ihrm2-test.itheima.net/api/company/department"
#         ysy4_header = {"Content-Type": "application/json", "Authorization": "5755f3f6-4dba-44da-b269-bc9929d26a58"}
#         ysy4_body = {"name": "周天狗", "code": "38"}
#         ysy4_reps = requests.post(url=ysy4_url, headers=ysy4_header, json=ysy4_body)
#         print(ysy4_reps.json())
#
#         assert 200 == ysy4_reps.status_code
#         assert True == ysy4_reps.json().get("success")
#         assert 10000 == ysy4_reps.json().get("code")
#         assert '操作成功！' == ysy4_reps.json().get("message")
#
#     def test_ysy5(self):
#         ysy4_url = "http://ihrm2-test.itheima.net/api/company/department/1552998403074551808"
#         ysy4_header = {"Content-Type": "application/json", "Authorization": "5755f3f6-4dba-44da-b269-bc9929d26a58"}
#         ysy4_body = {"name": "周大天狗", "code": "38"}
#         ysy4_reps = requests.put(url=ysy4_url, headers=ysy4_header, json=ysy4_body)
#         print(ysy4_reps.json())
#
#         assert 200 == ysy4_reps.status_code
#         assert True == ysy4_reps.json().get("success")
#         assert 10000 == ysy4_reps.json().get("code")
#         assert '操作成功！' == ysy4_reps.json().get("message")
#
#     def test_ysy6(self):
#         ysy4_url = "http://ihrm2-test.itheima.net/api/company/department/1552998403074551808"
#         ysy4_header = {"Authorization": "5755f3f6-4dba-44da-b269-bc9929d26a58"}
#         ysy4_reps = requests.delete(url=ysy4_url, headers=ysy4_header)
#         print(ysy4_reps.json())
#
#         assert 200 == ysy4_reps.status_code
#         assert True == ysy4_reps.json().get("success")
#         assert 10000 == ysy4_reps.json().get("code")
#         assert '操作成功！' == ysy4_reps.json().get("message")
#
#     def test_ysy7(self):
#         ysy4_url = "http://ihrm2-test.itheima.net/api/sys/user?page=1&size=10"
#         ysy4_header = {"Authorization": "5755f3f6-4dba-44da-b269-bc9929d26a58"}
#         ysy4_query = {"page": "1", "size": "1"}
#         ysy4_reps = requests.get(url=ysy4_url, headers=ysy4_header, json=ysy4_query)
#         print(ysy4_reps.json())
#
#         assert 200 == ysy4_reps.status_code
#         assert True == ysy4_reps.json().get("success")
#         assert 10000 == ysy4_reps.json().get("code")
#         assert '操作成功！' == ysy4_reps.json().get("message")
#
#     def test_ysy8(self):
#         ysy4_url = "http://ihrm2-test.itheima.net/api/sys/user"
#         ysy4_header = {"Content-Type": "application/json", "Authorization": "5755f3f6-4dba-44da-b269-bc9929d26a58"}
#         ysy4_body = {"username": "周天大狗", "mobile": "13838384384", "workNumber": "38"}
#         ysy4_reps = requests.post(url=ysy4_url, headers=ysy4_header, json=ysy4_body)
#         print(ysy4_reps.json())
#
#         assert 200 == ysy4_reps.status_code
#         assert True == ysy4_reps.json().get("success")
#         assert 10000 == ysy4_reps.json().get("code")
#         assert '操作成功！' == ysy4_reps.json().get("message")
